package com.hfzy.ihk.facade.linkcall.enums.KnowledgeBase;

import com.hfzy.ihk.common.facade.elasticsearch.ElasticsearchVersionRedisKey;
import com.hfzy.ihk.common.facade.elasticsearch.entity.ElasticsearchTable;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: ouyicong
 * @Date: 2018/8/12 16:15
 * @Description:
 */
public enum KnowledgeBaseRedisVersionKey implements ElasticsearchVersionRedisKey {

    TABLE_KNOWLEDGEBASE("KnowledgeBase_version","KnowledgeBase版本维护",KnowledgeBaseTables.KNOWLEDGEBASE);

    private String value;

    private String desc;

    private ElasticsearchTable table;

    private static Map<String,KnowledgeBaseRedisVersionKey> map=new HashMap<>();

    static{

        for(KnowledgeBaseRedisVersionKey value:KnowledgeBaseRedisVersionKey.values()){

            map.put(value.getValue(),value);

        }

    }
    public static KnowledgeBaseRedisVersionKey fromValue(String value) {
        KnowledgeBaseRedisVersionKey ret = map.get(value);
        if (ret != null) {
            return ret;
        } else {
            throw new IllegalArgumentException("No enum const " + KnowledgeBaseRedisVersionKey.class + "." + value);
        }
    }

    KnowledgeBaseRedisVersionKey(String value, String desc, ElasticsearchTable table) {
        this.value = value;
        this.desc = desc;
        this.table = table;
    }


    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public ElasticsearchTable getTable() {
        return table;
    }

    @Override
    public String getVersionKeyName() {

       String versionKeyName = getTable().getTableName()+":"+getValue();

        return versionKeyName;
    }
}
